package com.example;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

public class StreamOperations {

    // 假设有一个 Person 类
    public static class Person {
        private String name;
        private int age;

        // 构造函数、getter 和 setter 方法
        public Person(String name, int age) {
            this.name = name;
            this.age = age;
        }

        public String getName() { return name; }
        public void setName(String name) { this.name = name; }
        public int getAge() { return age; }
        public void setAge(int age) { this.age = age; }
    }

    public static void main(String[] args) {
        List<Person> people = Arrays.asList(
            new Person("Alice", 30),
            new Person("Bob", 20),
            new Person("Charlie", 25),
            new Person("David", 30),
            new Person("Eve", 20)
        );

        // 1. 过滤对象
        List<Person> adults = people.stream()
                                    .filter(person -> person.getAge() >= 25)
                                    .collect(Collectors.toList());

        System.out.println(adults);

    }
}
